import time
import xmlrpclib

def main():
  p = xmlrpclib.ServerProxy('http://localhost:8083')
  vm = p.listAvailableVMs()
  try:
    p.start(vm[0])
  except Exception as e: print "Hoops!"
  tic = time.time()
  while 1:
    try:
      p.ping(vm[0])
      break
    except Exception as e: print "oh :("

  toc = time.time()
  print "Tic", tic
  print "Toc", toc

  dur = float(toc) - float(tic)
  print "Duration: ", dur
  

if __name__ == "__main__":
  main()
